<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>我的图书 - 图书管理系统</title>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
    <style>
        :root {
            --primary-color: #3f51b5;
            --secondary-color: #f50057;
            --bg-color: #f5f5f5;
            --card-color: #ffffff;
            --table-header-bg: #eef1fb;
            --table-hover-bg: #f5f7ff;
            --text-color: #333333;
            --text-light: #666666;
            --border-color: #e2e8f0;
            --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            --border-radius: 8px;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
        }

        /* 修改: 添加html和body的高度为100% */
        html, body {
            height: 100%;
        }

        /* 修改: 添加页面包装器，使用flex布局 */
        body {
            background-color: var(--bg-color);
            color: var(--text-color);
            line-height: 1.6;
            display: flex;
            flex-direction: column;
            min-height: 100vh;
        }

        .navbar {
            background-color: var(--primary-color);
            color: white;
            padding: 1rem 2rem;
            display: flex;
            justify-content: space-between;
            align-items: center;
            box-shadow: var(--shadow);
            position: sticky;
            top: 0;
            z-index: 100;
        }

        .navbar-brand {
            font-size: 1.5rem;
            font-weight: bold;
            display: flex;
            align-items: center;
        }

        .navbar-brand i {
            margin-right: 0.5rem;
        }

        .navbar-links {
            display: flex;
            gap: 1.5rem;
        }

        .navbar a {
            color: white;
            text-decoration: none;
            padding: 0.5rem 0;
            position: relative;
            font-weight: 500;
            transition: color 0.3s;
        }

        .navbar a:hover {
            color: rgba(255, 255, 255, 0.8);
        }

        .navbar a::after {
            content: '';
            position: absolute;
            width: 0;
            height: 2px;
            background-color: white;
            bottom: 0;
            left: 0;
            transition: width 0.3s;
        }

        .navbar a:hover::after {
            width: 100%;
        }

        /* 修改: 添加main标签样式，使其占用剩余空间 */
        main {
            flex: 1;
        }

        .container {
            max-width: 1200px;
            margin: 2rem auto;
            padding: 2rem;
            background: var(--card-color);
            border-radius: var(--border-radius);
            box-shadow: var(--shadow);
        }

        .page-title {
            color: var(--primary-color);
            margin-bottom: 1.5rem;
            padding-bottom: 1rem;
            border-bottom: 2px solid var(--primary-color);
            font-size: 1.8rem;
        }

        .action-area {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 1.5rem;
            flex-wrap: wrap;
            gap: 1rem;
        }

        .search-form {
            flex: 1;
            min-width: 250px;
        }

        .search-form form {
            display: flex;
            width: 100%;
        }

        .search-form input {
            flex: 1;
            padding: 0.75rem 1rem;
            border: 1px solid var(--border-color);
            border-radius: var(--border-radius) 0 0 var(--border-radius);
            font-size: 0.9rem;
            transition: border-color 0.3s, box-shadow 0.3s;
        }

        .search-form input:focus {
            outline: none;
            border-color: var(--primary-color);
            box-shadow: 0 0 0 2px rgba(63, 81, 181, 0.25);
        }

        .search-form button {
            padding: 0.75rem 1.25rem;
            background-color: var(--primary-color);
            color: white;
            border: none;
            border-radius: 0 var(--border-radius) var(--border-radius) 0;
            cursor: pointer;
            transition: background-color 0.3s;
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }

        .search-form button:hover {
            background-color: #303f9f;
        }

        .btn {
            display: inline-flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.75rem 1.25rem;
            background-color: var(--primary-color);
            color: white;
            text-decoration: none;
            border-radius: var(--border-radius);
            font-size: 0.9rem;
            font-weight: 500;
            transition: all 0.3s;
            border: none;
            cursor: pointer;
        }

        .btn:hover {
            background-color: #303f9f;
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
        }

        .btn-danger {
            background-color: var(--secondary-color);
        }

        .btn-danger:hover {
            background-color: #c51162;
        }

        .table-container {
            overflow-x: auto;
            margin-top: 1rem;
            border-radius: var(--border-radius);
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
        }

        .table {
            width: 100%;
            border-collapse: collapse;
            border-radius: var(--border-radius);
            overflow: hidden;
        }

        .table th, .table td {
            padding: 1rem;
            text-align: left;
        }

        .table th {
            background-color: var(--table-header-bg);
            font-weight: 600;
            color: var(--primary-color);
            border-bottom: 2px solid var(--primary-color);
            white-space: nowrap;
        }

        .table td {
            border-bottom: 1px solid var(--border-color);
        }

        .table tr:last-child td {
            border-bottom: none;
        }

        .table tr:hover {
            background-color: var(--table-hover-bg);
        }

        .action-buttons {
            display: flex;
            gap: 0.5rem;
            white-space: nowrap;
        }

        .table .btn {
            padding: 0.5rem 0.75rem;
            font-size: 0.8rem;
        }

        .empty-state, .no-results {
            text-align: center;
            padding: 3rem 2rem;
            background-color: rgba(63, 81, 181, 0.05);
            border-radius: var(--border-radius);
            margin: 2rem 0;
        }

        .empty-state img, .no-results img {
            width: 150px;
            height: auto;
            margin-bottom: 1.5rem;
            opacity: 0.7;
        }

        .empty-state h3, .no-results h3 {
            font-size: 1.5rem;
            color: var(--primary-color);
            margin-bottom: 1rem;
        }

        .empty-state p, .no-results p {
            color: var(--text-light);
            margin-bottom: 1.5rem;
            font-size: 1rem;
            max-width: 500px;
            margin-left: auto;
            margin-right: auto;
        }

        .no-results a {
            color: var(--primary-color);
            text-decoration: none;
            font-weight: 500;
        }

        .no-results a:hover {
            text-decoration: underline;
        }

        /* 修改: 调整footer样式 */
        footer {
            background-color: var(--primary-color);
            color: white;
            text-align: center;
            padding: 1.5rem 0;
            width: 100%;
        }

        @media (max-width: 768px) {
            .navbar {
                flex-direction: column;
                padding: 1rem;
            }

            .navbar-brand {
                margin-bottom: 1rem;
            }

            .action-area {
                flex-direction: column;
                align-items: stretch;
            }

            .container {
                padding: 1.5rem 1rem;
                margin: 1rem;
            }

            .table th, .table td {
                padding: 0.75rem 0.5rem;
                font-size: 0.9rem;
            }

            .action-buttons {
                flex-direction: column;
                gap: 0.3rem;
            }
        }
    </style>
</head>
<body>
<nav class="navbar">
    <div class="navbar-brand">
        <i class="fas fa-book"></i>
        <span>图书管理系统</span>
    </div>
    <div class="navbar-links">
        <a href="/"><i class="fas fa-home"></i> 首页</a>
        <a href="/book/list"><i class="fas fa-list"></i> 我的图书</a>
        <a href="/logout"><i class="fas fa-sign-out-alt"></i> 退出登录</a>
    </div>
</nav>

<!-- 添加main标签包裹主要内容 -->
<main>
    <div class="container">
        <h1 class="page-title">我的图书列表</h1>

        <!-- 搜索框和添加按钮 -->
        <div class="action-area">
            <div class="search-form">
                <form action="/book/list" method="get">
                    <input type="text" name="keyword" placeholder="搜索书名或作者..." th:value="${keyword}">
                    <button type="submit"><i class="fas fa-search"></i> 搜索</button>
                </form>
            </div>

            <!-- 添加图书按钮 -->
            <div>
                <a href="/book/add" class="btn"><i class="fas fa-plus"></i> 添加新图书</a>
            </div>
        </div>

        <!-- 有搜索关键词但无结果时显示 -->
        <div th:if="${keyword != null && keyword != '' && (books == null || books.isEmpty())}" class="no-results">
            <i class="fas fa-search" style="font-size: 3rem; color: var(--primary-color); margin-bottom: 1rem;"></i>
            <h3>未找到相关图书</h3>
            <p>您搜索的 "<span th:text="${keyword}"></span>" 没有匹配的结果。</p>
            <p>试试其他关键词，或者<a href="/book/list">查看全部图书</a>。</p>
        </div>

        <!-- 图书列表 -->
        <div th:if="${books != null && !books.isEmpty()}" class="table-container">
            <table class="table">
                <thead>
                <tr>
                    <th>书名</th>
                    <th>作者</th>
                    <th>出版社</th>
                    <th>出版日期</th>
                    <th>ISBN</th>
                    <th>分类</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <tr th:each="book : ${books}">
                    <td th:text="${book.title}"></td>
                    <td th:text="${book.author}"></td>
                    <td th:text="${book.publisher}"></td>
                    <td th:text="${#dates.format(book.publicationDate, 'yyyy-MM-dd')}"></td>
                    <td th:text="${book.isbn}"></td>
                    <td th:text="${book.category}"></td>
                    <td class="action-buttons">
                        <a th:href="@{/book/edit/{id}(id=${book.id})}" class="btn"><i class="fas fa-edit"></i> 编辑</a>
                        <a th:href="@{/book/delete/{id}(id=${book.id})}" class="btn btn-danger delete-book"><i class="fas fa-trash-alt"></i> 删除</a>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>

        <!-- 没有图书且没有搜索关键词时显示 -->
        <div th:if="${(keyword == null || keyword == '') && (books == null || books.isEmpty())}" class="empty-state">
            <i class="fas fa-books" style="font-size: 3.5rem; color: var(--primary-color); margin-bottom: 1rem;"></i>
            <h3>您的书架还是空的</h3>
            <p>您还没有添加任何图书到个人书架中。</p>
            <p>点击下方按钮开始添加您的第一本图书吧！</p>
            <a href="/book/add" class="btn"><i class="fas fa-plus"></i> 添加新图书</a>
        </div>
    </div>
</main>

<footer>
    <p>&copy; 2025 图书管理系统 - 让图书管理更简单</p>
</footer>

<script src="/js/script.js"></script>
</body>
</html>